//
//  HYOUTopicMoreTableView.m
//  BestGift
//
//  Created by 温晓宇 on 16/1/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HYOUTopicMoreTableView.h"
#import "HYOUTopicMoreTableViewCell.h"
@interface HYOUTopicMoreTableView ()<UITableViewDataSource, UITableViewDelegate>



@end

@implementation HYOUTopicMoreTableView
-(void)dealloc{
    [_myTableView release];
    [_allArray release];
    [super dealloc];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews{
    self.myTableView = [[HYOUBaseTableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
    self.myTableView.backgroundColor = [UIColor whiteColor];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self addSubview:self.myTableView];
    [_myTableView release];
    
    [self.myTableView registerClass:[HYOUTopicMoreTableViewCell class] forCellReuseIdentifier:@"cell"];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.allArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HYOUTopicMoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.model = [self.allArray objectAtIndex:indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    HYOUOneCellModel *model = [self.allArray objectAtIndex:indexPath.row];
    NSString *url = [NSString stringWithFormat:@"http://api.liwushuo.com/v2/collections/%@/posts?gender=1&generation=2&limit=20&offset=0",model.id];
    NSLog(@"%@",url);
    [self.delegate topicMoreDetailWeb:url];
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 150;
}
-(void)setAllArray:(NSMutableArray *)allArray{
    if (_allArray != allArray) {
        [_allArray release];
        _allArray = [allArray retain];
    }
    [self.myTableView reloadData];
}
@end
